.TH std::weak_ptr::operator= 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::weak_ptr::operator= \- std::weak_ptr::operator=

.SH Synopsis
   weak_ptr& operator=( const weak_ptr& r ) noexcept;      \fB(1)\fP \fI(since C++11)\fP
   template< class Y >                                     \fB(2)\fP \fI(since C++11)\fP
   weak_ptr& operator=( const weak_ptr<Y>& r ) noexcept;
   template< class Y >                                     \fB(3)\fP \fI(since C++11)\fP
   weak_ptr& operator=( const shared_ptr<Y>& r ) noexcept;
   weak_ptr& operator=( weak_ptr&& r ) noexcept;           \fB(4)\fP \fI(since C++11)\fP
   template< class Y >                                     \fB(5)\fP \fI(since C++11)\fP
   weak_ptr& operator=( weak_ptr<Y>&& r ) noexcept;

   Replaces the managed object with the one managed by r. The object is shared with r.
   If r manages no object, *this manages no object too.

   1-3) Equivalent to std::weak_ptr<T>(r).swap(*this).
   4,5) Equivalent to std::weak_ptr<T>(std::move(r)).swap(*this).

.SH Parameters

   r - smart pointer to share an object with

.SH Return value

   *this

.SH Notes

   The implementation may meet the requirements without creating a temporary weak_ptr
   object.

   Defect reports

   The following behavior-changing defect reports were applied retroactively to
   previously published C++ standards.

      DR    Applied to           Behavior as published            Correct behavior
   LWG 2315 C++11      move semantic was not enabled for weak_ptr enabled

.SH See also

   constructor   creates a new weak_ptr
                 \fI(public member function)\fP
   swap          swaps the managed objects
                 \fI(public member function)\fP
